package com.qipay.baas.mapper;

import com.qipay.baas.model.ActionDocDetail;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface ActionDocDetailMapper {
    @Delete({
        "delete from action_doc_detail",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into action_doc_detail (doc_id, title, ",
        "pid, create_time, ",
        "parnt_cate_name, info)",
        "values (#{docId,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, ",
        "#{pid,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{parntCateName,jdbcType=VARCHAR}, #{info,jdbcType=LONGVARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(ActionDocDetail record);

    @InsertProvider(type=ActionDocDetailSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insertSelective(ActionDocDetail record);

    @Select({
        "select",
        "id, doc_id, title, pid, create_time, parnt_cate_name, info",
        "from action_doc_detail",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="doc_id", property="docId", jdbcType=JdbcType.INTEGER),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="pid", property="pid", jdbcType=JdbcType.INTEGER),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="parnt_cate_name", property="parntCateName", jdbcType=JdbcType.VARCHAR),
        @Result(column="info", property="info", jdbcType=JdbcType.LONGVARCHAR)
    })
    ActionDocDetail selectByPrimaryKey(Integer id);

    @UpdateProvider(type=ActionDocDetailSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(ActionDocDetail record);

    @Update({
        "update action_doc_detail",
        "set doc_id = #{docId,jdbcType=INTEGER},",
          "title = #{title,jdbcType=VARCHAR},",
          "pid = #{pid,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "parnt_cate_name = #{parntCateName,jdbcType=VARCHAR},",
          "info = #{info,jdbcType=LONGVARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(ActionDocDetail record);

    @Update({
        "update action_doc_detail",
        "set doc_id = #{docId,jdbcType=INTEGER},",
          "title = #{title,jdbcType=VARCHAR},",
          "pid = #{pid,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "parnt_cate_name = #{parntCateName,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ActionDocDetail record);
}